using ExampleWebApplication.Entities;
using NHibernate.Mapping.ByCode.Conformist;

namespace ExampleWebApplication.Infraestruture.NHibernate.EntityMappings
{
    public class OrderDetailMap : ClassMapping<OrderDetail>
    {
        public OrderDetailMap()
        {
            Table("`Order Details`");
            ComposedId(x =>
            {
                //x.Property(c => c.OrderID, map => map.Column("OrderID"));
                x.ManyToOne(c => c.Order, map => map.Column("OrderID"));
                x.Property(c => c.ProductID, map => map.Column("ProductID"));
            });
            Property(x => x.UnitPrice, map => { map.Column("UnitPrice"); map.NotNullable(true); });
            Property(x => x.Quantity, map => { map.Column("Quantity"); map.NotNullable(true); });
            Property(x => x.Discount, map => { map.Column("Discount"); map.NotNullable(true); });
            //ManyToOne(x => x.Order, map => map.Column("OrderID"));
            ManyToOne(x => x.Product, map => map.Column("ProductID"));
        }
    }
}
